import Toast from '../../../miniprogram_npm/vant-weapp/toast/toast';
var server = require('../../../utils/server.js');
Page({
	data: {
		orderId: '',
        show:false,
        imgwidth:'',
        erweima:'',
        weixin_pay:'',
        alipay_pay:'',
	},
	onLoad: function (options) {
        wx.getSystemInfo({
            success:(res)=>{
                this.setData({
                    imgwidth:res.windowWidth *0.7
                })
            }
        })
	},
    onClose() {
        this.setData({ show: false });
    },
    show(e){
        let _this = this;
        let str = e.currentTarget.dataset.a;
        // server.postJSON('/seller/getpay', {
        //     shop_id: wx.getStorageSync('shop_id')
        // }, res => {
        //     _this.setData({
        //         weixin_pay: res.data.list.weixin_pay,
        //         alipay_pay: res.data.list.alipay_pay
        //     })
        // })
        server.send('/seller/getpay', 'POST',{
            shop_id: wx.getStorageSync('shop_id')
        }).then(res => {
            _this.setData({
                weixin_pay: res.list.weixin_pay,
                alipay_pay: res.list.alipay_pay
            })
        })
        if (str==1){
            _this.setData({
                erweima: _this.data.weixin_pay
            })
            if (!_this.data.weixin_pay){
                Toast('未上传微信二维码');
                return false;
            }
        } else if (str==2){
            _this.setData({
                erweima: _this.data.alipay_pay
            })
            if (!_this.data.alipay_pay) {
                Toast('未上传支付宝二维码');
                return false;
            }
        }
        this.setData({ show: true });
    }
})